package com.next

class RiskWarningConfigLog
{

    String logs
    String status

    Date startTime
    Date endTime
    Date createdDate = new Date()
    Date modifiedDate = new Date()

    User user
    User createBy
    User modifyBy
    Account account

    static belongsTo = [riskWarningConfig: RiskWarningConfig]

    static constraints =
        {
            logs type: "text", nullable: true, blank: true
            createdDate nullable: true, blank: true
            modifiedDate nullable: true, blank: true
            startTime nullable: true, blank: true
            endTime nullable: true, blank: true
            status nullable: true, blank: true
            status inList: ['Success', 'Failed']

            user nullable: true, blank: true
            createBy nullable: true, blank: true
            modifyBy nullable: true, blank: true
            account nullable: true, blank: true
        }

    def springSecurityService

    def beforeInsert()
    {
        def username = springSecurityService?.getPrincipal()?.username
        createBy = User.findByUsername(username)
    }

    def beforeUpdate()
    {
        modifiedDate = new Date()
        def username = springSecurityService?.getPrincipal()?.username
        modifyBy = User.findByUsername(username)
    }

}